home *** CD-ROM | disk | FTP | other *** search
- Path: newsfeeds.ans.net!butch!news
- From: Rick Richert <richert>
- Newsgroups: comp.lang.c++
- Subject: Global Objects with argc & argv
- Date: 20 Feb 1996 19:07:21 GMT
- Organization: Org. 81-20
- Message-ID: <4gd659$95@butch.lmsc.lockheed.com>
- NNTP-Posting-Host: sgi564.msd.lmsc.lockheed.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.1N (X11; I; IRIX 5.3 IP22)
- X-URL: news:comp.lang.c++
-
- I have some global objects defined outside the main routine and I would
- like to pass the argc and argv values to their constructors. For example,
-
-
- SomeClass obj( argc, argv);
-
- int main( int argc, char **argv) {
-
- blah, blah, blah
-
- }
-
- Unfortunately, the compiler tells me that argc and argv are not defined or else
- not available for obj.
-
- Currently, I get around this problem by creating the global obj and then inside
- of main, I initialize obj via a method that takes argc and argv.
-
- I would prefer to pass the arg vars to the constructor. Does anyone know how I
- can pass the arg vars without being inside of main?
-
- --
- Rick Richert
- richert@lmsc.lockheed.com
-
-